﻿using System;
using System.Windows.Forms;

namespace CalcSharp.MDIUI.Plugin
{
    /// <summary>
    /// A simple Contrast & Brightness setup dialog
    /// </summary>
    public partial class ContrastBrigthnes : Form
    {
        private bool contrast;

        public ContrastBrigthnes()
        {
            InitializeComponent();
            this.contrast = false;
        }

        private void BtnReset_Click(object sender, EventArgs e)
        {
            this.Adjuster.Value = 0;
        }

        private void Adjuster_Scroll(object sender, EventArgs e)
        {
            if (this.Adjuster.Value != 0) this.BtnReset.Visible = true;
            else this.BtnReset.Visible = false;
        }

        /// <summary>
        /// Switches between Contrast and brightness dialog types
        /// </summary>
        public bool ContrastDialog
        {
            get
            {
                return this.contrast;
            }
            set
            {
                this.contrast = value;
                if (value)
                {
                    this.Text = "Contrast";
                    this.label1.Text = "Adjust contrast value:";
                }
                else
                {
                    this.Text = "Brightness";
                    this.label1.Text = "Adjust brightness value:";
                }
            }
        }

        /// <summary>
        /// Gets or sets the adjuster value
        /// </summary>
        public int Value
        {
            get { return this.Adjuster.Value; }
            set
            {
                if (value > this.Adjuster.Maximum) this.Adjuster.Value = this.Adjuster.Maximum;
                else if (value < this.Adjuster.Minimum) this.Adjuster.Value = this.Adjuster.Maximum;
                else this.Adjuster.Value = value;
            }
        }
    }
}
